package login.handler;

import java.util.Map;

import org.apache.mina.core.session.IoSession;

import connect.ClientMessageCode;
import connect.Transmitter;
import util.ByteBuffer;
import app.App;
import backlet.LogicHandler;

public class LoginHandler extends LogicHandler {

	@Override
	public void deal(ByteBuffer data, int sessionId) 
	{
		Map<Integer, IoSession> map = App.getInstance().connects;
		
		for(Integer id:map.keySet()	)
		{
			if(id == sessionId)
			{
				data.clear();
				data.writeInt(ClientMessageCode.PLAYER.BID);
				data.writeInt(ClientMessageCode.PLAYER.PLAYER_ADD);
				data.writeInt(sessionId);
				Transmitter.sendToOthers(sessionId, data);
				
			}else
			{
				data.clear();
				data.writeInt(ClientMessageCode.PLAYER.BID);
				data.writeInt(ClientMessageCode.PLAYER.PLAYER_ADD);
				data.writeInt(id);
				Transmitter.sendToClient(sessionId, data);
			}
		
		}
	}

}
